package com.csnf.service.impl;

import csnf.com.entity.*;
import com.csnf.mapper.MerchantMapper;
import com.csnf.service.MerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class MerchantServiceImpl implements MerchantService {
    @Autowired
    MerchantMapper merchantMapper;
    @Override
    public int merchantLogin(Merchant merchant){
        int loginFlag = merchantMapper.merchantLogin(merchant);
        return loginFlag;


    }
    @Override
    public int merchantRegister(Merchant merchant){
        return merchantMapper.merchantRegister(merchant);
    }

    @Override
    public ArrayList<Merchant> selectAll(Merchant merchant) {
        int id=merchantLogin(merchant);
        if(id==1){
            ArrayList<Merchant> merchantList = merchantMapper.selectAll(merchant);
            return merchantList;
        }else {
            return null;
        }
    }

    @Override
    public Merchant selectMerchant(int id) {
        return merchantMapper.selectMerchant(id);
    }

    @Override
    public int updateMerchant(Merchant merchant) {
        return merchantMapper.updateMerchant(merchant);
    }
}
